import 'package:fluent_ui/fluent_ui.dart';
import 'package:provider/provider.dart';

import '../view_type.dart';
import 'test_batch_view_edit.dart';
import 'test_batch_view_list.dart';
import 'test_batch_view_model.dart';

/// 考试批次:视图入口
class TestBatchViewMain extends StatefulWidget {
  final ViewType type;
  final String? id;

  const TestBatchViewMain({super.key, required this.type, this.id});

  @override
  State<TestBatchViewMain> createState() => _TestBatchViewMainState();
}

class _TestBatchViewMainState extends State<TestBatchViewMain> {
  @override
  Widget build(final BuildContext context) =>
      ChangeNotifierProvider<TestBatchViewModel>(
        create: (_) => TestBatchViewModel(),
        builder: (_, __) {
          if (widget.type == ViewType.edit) {
            return TestBatchViewEdit(id: widget.id);
          }
          return const TestBatchViewList();
        },
      );
}
